Skip to content

Sync python-import with the updated tutorial - #894

Open
realpython-bot wants to merge 1 commit into
masterfrom
maintenance/python-import-20261018
Open

realpython-bot wants to merge 1 commit into
masterfrom
maintenance/python-import-20261018

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Companion to the maintenance update of Python import: Advanced Techniques and Tips.

What changed

  • population_quiz/population_quiz.py: random.sample(population.keys(), ...) raises TypeError: Population must be a sequence since Python 3.11. It now passes list(population).
  • plugins.py: importlib.resources.contents() is deprecated since Python 3.11. _import_all() now lists files with resources.files(package).iterdir(), matching the updated article.

Links

Verification (Python 3.14.6)

  • import greeter; greeter.greetings() returns ['hello', 'howdy', 'yo'] and greeter.greet("howdy", "Guido") works with -W error (no DeprecationWarning).
  • population_quiz.py ran through several questions against a stub CSV (the real UN WPP2019 file is no longer downloadable, tracked on the card as a full-update item).
  • uvx ruff@0.14.1 format --check python-import and uvx ruff@0.14.1 check python-import pass.

Note: population_quiz/data/README.md still points at the retired WPP2019 download. Switching to WPP2024 is left for the full update.

🤖 Generated with Claude Code

…nced Techniques and Tips

- population_quiz.py: pass list(population) to random.sample(), which no longer accepts dict views (Python 3.11+)
- plugins.py: replace deprecated importlib.resources.contents() with files().iterdir()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant